<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Linkslistsmedias extends Model
{
    protected $table = 'links_lists_medias';
    protected $primaryKey = 'id';

    public static function getLastMedia($links_id,$img)
    {
        return self::where("img",$img)->where("links_id",$links_id)->orderBy("id","DESC")->first();
    }

    public static function insertLinksListsMedia($links_id,$img,$media_id,$created_at)
    {
        return self::insert(["links_id"=>$links_id,"img"=>$img,"media_id"=>$media_id,"created_at"=>$created_at]);
    }

    public static function deleteMedia($links_id,$img)
    {
        return self::where("img",$img)->where("links_id",$links_id)->delete();
    }

}
